#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
bool sushu(int n)
{
	if (n == 2)return true;
	for (int i = 2; i < sqrt(n) + 1; i++)
	{
		if (n % i == 0)return false;
	}
	return true;
}
int main()
{
	int a, b, tmp, sum, ss[1000 + 5] = { 0 };
	for (int i = 2; i <= 1000; i++)if (sushu(i))ss[i] = 1;
	while (cin >> a >> b)
	{
		sum = 0;
		if (a > b) { tmp = a; a = b; b = tmp; }
		for (int i = a; i <= b; i++)sum += ss[i];
		cout << sum << endl;
	}
	return 0;
}

